<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/5
 * Time: 16:16
 */
namespace app\index\validate;

use think\Validate;

class Product extends Validate
{
    protected $rule =[
                    'image'  =>'require|array|min:1',  //图片
                    'product_cate' => 'require|number', //商品类型
                    'product_condition' => 'require|number|between:1,7',//商品成色
                    'is_shelf' => 'require|number|between:1,11', //库存状态
                    'procurement_status' => 'require|number|between:1,4',//采购类别
                    'product_sn' => 'require',//商品货号
                    'systematics' => 'require|array',//商品类别
                    'stock' => 'require|number|between:1,120',//商品数量
                    'price' => 'require|float|gt:0',//销售价
                    'peer_price' => 'require|float|gt:0',//同行价
                    'phone_number'  => ['regex'=>'/^((13[0-9])|(14[4,7])|(15[0-3,5-9])|16[6]|(17[0,3,5-8])|(18[0-9])|(19[89]))\d{8}$/'],

    ];

    protected $message = [
            'image.require'  => '商品图片记得上传',
            'image.array'  => '商品图片是数组形式',
            'image.min'  => '必须上传至少一张商品图片',
            'product_cate.require' => '商品类型要选择',
            'product_cate.number' => '商品类型传数字',
            'product_condition.require' => '商品成色要选择',
            'product_condition.number' => '商品成色必须传数字',
            'product_condition.between' => '商品成色必须传1-7数字',
            'is_shelf.require' => '库存状态必填',
            'is_shelf.number' => '库存状态必须传数字',
            'is_shelf.between' => '库存状态必须传1-11的数字',
            'procurement_status.require' => '采购类别必选',
            'procurement_status.number' => '采购类别必须传数字',
            'procurement_status.between' => '采购类别必须传1-4数字',
            'product_sn.require' => '商品货号不能空着，请选择商品类别，系统自动生成货号',
            'systematics.require' => '商品类别必填',
            'systematics.array' => '商品类别必须传数组',
            'stock.require' => '商品数量必填',
            'stock.number' => '商品数量必须是数字',
            'stock.between' => '商品数量必须在1-120中间',
            'price.require' => '销售价必填',
            'price.float' => '销售价是浮点类型',
            'price.gt' => '销售价必须大于0',
            'peer_price.require' => '同行价必填',
            'peer_price.float' => '同行价是浮点类型',
            'peer_price.gt' => '同行价必须大于0',
            'phone_number.regex'  => '不是一个被认可的手机号'
        ];
}